package com.ww7h.ui.base.ui.adapter.item

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import com.ww7h.ui.base.ui.adapter.model.RecyclerViewModel
import com.ww7h.ui.base.ui.adapter.RecyclerViewHolder

/**
 * ================================================
 * 描述：
 * 来源：     Android Studio.
 * 项目名：   BigObj
 * 包名：     com.ww7h.ui.base.ui.adapter.item
 * 创建时间：  2020/11/6 01:38
 * @author   ww
 * ================================================
 */
    abstract class ItemRecyclerView<M: RecyclerViewModel, VDB: ViewDataBinding>(context: Context, parent: ViewGroup) {

        val binding: VDB by lazy {
            DataBindingUtil.inflate(LayoutInflater.from(context), getItemLayoutId(), parent, false) as VDB
        }

        val viewHolder: RecyclerViewHolder<M, VDB, out ItemRecyclerView<M, VDB>> by lazy {
            RecyclerViewHolder(this)
        }

        val rootView: View by lazy {
            binding.root
        }

        abstract fun dataBinding(m: M, position: Int)

        abstract fun getItemLayoutId(): Int
    }

